﻿<%@ codepage=65001%>
<!-- #include file="conn.asp" -->
<!--#include file="UpLoad_Class.asp"-->
<!-- #include file="log.asp" -->
<%
Session.CodePage=65001
Response.Charset="utf-8"

'sType = request("sType")
'
'if (IsEmpty(request("id")) or request("id")="" ) then
'	id=0
'else
'	id=cint(trim(request("id")))
'end if
'
'wangdianName=request("wangdianName")
'wangdianNumber=request("wangdianNumber")
'landmarksName=request("landmarksName")
'positionAddress = request("positionAddress")
'lng = request("lng")
'lat = request("lat")
'
'if sType = "add" then
'	'on error resume next
'	set rs= server.createobject("adodb.recordset")
'	if id>0 then    'update
'		sql="update [uploadData] set [wangdianName]='"&wangdianName&"',[wangdianNumber]='"&wangdianNumber&"',[landmarksName]='"&landmarksName&"',[positionAddress]='"&positionAddress&"',[lng]='"&lng&"',[lat]='"&lat&"',[v1]='0' where id="&id
'		conn.execute(sql)
'		'sql="delete from userInfo where id="&id
'		'conn.execute(sql)
'		'sql="insert into userInfo ([username],[password],[p]) values ('"&username&"','"&password&"','"&p&"')"
'		'conn.execute(sql)
'		if err.number=0 then
'			response.write "true"
'		else
'			response.write "false"
'		end if
'	else
'		sqlstr = "select count(*) as cc from uploadData where wangdianName='"&wangdianName&"'"
'		rs.open sqlstr,conn,1,1
'		if rs("cc") = 0 then
'			sql="insert into uploadData ([wangdianName],[wangdianNumber],[landmarksName],[positionAddress],[lng],[lat],[v1]) values ('"&wangdianName&"','"&wangdianNumber&"','"&landmarksName&"','"&positionAddress&"','"&lng&"','"&lat&"','0')"
'			conn.execute(sql)
'			if err.number=0 then
'				response.write "true"
'			else
'				response.write "false"
'			end if
'			str = "网点名称："&wangdianName&vbcrlf&"网点编号："&wangdianNumber&vbcrlf&"重要地标名称："&landmarksName&vbcrlf&"地址："&positionAddress&vbcrlf&"经度："&lng&vbcrlf&"纬度："&lat&vbcrlf&"||"&err.number&"===="&err.Description
'			'logStr = Write_Log(str)
'		else
'			response.write "false"
'			str = wangdianName&"(网点名称重复)"
'			'logStr = Write_Log(str)
'		end if
'	end if
'elseif sType = "del" then
'	arrvalue=split(id,",")
'    for i=0 to ubound(arrvalue)
'      	on error resume next
'	  	sql="delete from uploadData where id=" & arrvalue(i)
'		conn.execute(sql)
'    next
'else
'end if
'
'conn.close



sType = request("sType")
set rs= server.createobject("adodb.recordset")
if sType = "add" then
	dim upload
	set upload = new AnUpLoad
	upload.Charset="UTF-8"
	upload.Exe = "jpg|bmp|jpeg|gif|png"
	upload.MaxSize = 10 * 1024 * 1024     '设置最大上传限制
	'upload.SingleSize=500*1024          '设置单文件最大上传限制为500KB,按字节计；默认为不限制
	upload.GetData()
	'upload.CodePage = 65001
	
	
	'saleId=0
'	saleAreaId = 0
'	city = 0
'	district = 0
	
	if (IsEmpty(replace(upload.forms("id"),"'","")) or replace(upload.forms("id"),"'","")="" ) then
		id=0
	else
		id=cint(replace(upload.forms("id"),"'",""))
	end if
	
	wangdianName=replace(upload.forms("wangdianName"),"'","")
	wangdianNumber=replace(upload.forms("wangdianNumber"),"'","")
	landmarksName=replace(upload.forms("landmarksName"),"'","")
	positionAddress = replace(upload.forms("positionAddress"),"'","")
	lng = replace(upload.forms("getPositionLngValue"),"'","")
	lat = replace(upload.forms("getPositionLatValue"),"'","")
	lat = replace(upload.forms("getPositionLatValue"),"'","")
	userId = replace(upload.forms("userIdOnlyMsg"),"'","")
	imgUrlCaiJi = replace(upload.forms("imgUrlCaiJi"),"'","")
	
	if wangdianName <> "" then
		if imgUrlCaiJi <> "" then
			if id>0 then    'update
				sql="update [uploadData] set [wangdianName]='"&wangdianName&"',[wangdianNumber]='"&wangdianNumber&"',[landmarksName]='"&landmarksName&"',[positionAddress]='"&positionAddress&"',[lng]='"&lng&"',[lat]='"&lat&"',[wangdianPhone]='"&imgUrlCaiJi&"',[v1]='0' where id="&id
				conn.execute(sql)
				if err.number=0 then
					response.write "true"
				else
					response.write "false"
				end if
			else
				sql="insert into uploadData ([wangdianName],[wangdianNumber],[landmarksName],[positionAddress],[lng],[lat],[wangdianPhone],[v1]) values ('"&wangdianName&"','"&wangdianNumber&"','"&landmarksName&"','"&positionAddress&"','"&lng&"','"&lat&"','"&imgUrlCaiJi&"','0')"
				conn.execute(sql)
				if err.number=0 then
					response.write "true"
				else
					response.write "false"
				end if
			end if
		end if
		'response.Write "{success:true,msg:"&strResult&"}"
	else
		if upload.ErrorID>0 then
			'response.Write upload.Description
			response.Write "{success:false,msg:1}"
		else
			dim savpath1,sFileName1,strResult1,stateFile1
			stateFile1 = 1
			for each i in upload.files(-1)
				set file = upload.files(i)
				if not(file is nothing) then
					stateFile1 = 0
				end if
			next
			logStr = Write_Log("采集照片")
			if stateFile1 = 0 then
				for each f in upload.files(-1)
					dim file1
					set file1 = upload.files(f)
					savepath = "upfile/"&userId&"/"
					if not(file1 is nothing) then
						result = file1.saveToFile(savepath,0,true)
						sFileName1 = savepath&""&file1.filename
						
						if result then
							strResult1 = 0
							'response.write sFileName1
						else
							strResult1 = 1
							exit for
						end if
					end if
					set file1 = nothing
					set rs = nothing
				next
			else
				strResult1 = 0
			end if
			'response.Write "{success:true,msg:"&strResult1&",file:'"&sFileName1&"'}"
			response.Write "<script type='text/javascript'>window.top.window.setFile('"&sFileName1&"')</script>"
		end if
	end if
elseif sType = "del" then
	arrvalue=split(id,",")
    for i=0 to ubound(arrvalue)
      	on error resume next
	  	sql="delete from uploadData where id=" & arrvalue(i)
		conn.execute(sql)
    next
else
end if

set upload = nothing
conn.close
%>